﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace CloudWars
{
    public class Player
    {
        public string Name { get; set; }
        public List<Unit> Units { get; private set; }
        public Color Color { get; set; }
        public List<Player> PlayerList { get; private set; }
        public PlayerIndex Controller { get; set; }

        public Player(string name, PlayerIndex controller, List<Player> playerList, OnPlayerDefeatDelegate onDefeat)
        {
            Name = name;
            Units = new List<Unit>();

            PlayerList = playerList;
            PlayerList.Add(this);
            OnDefeat = onDefeat;
            Controller = controller;
        }

        public void Defeat()
        {
            PlayerList.Remove(this);
            OnDefeat(this);
        }

        public delegate void OnPlayerDefeatDelegate(Player player);
        public event OnPlayerDefeatDelegate OnDefeat;
    }
}
